﻿using System.ComponentModel.Composition;
using AppsGenerator.Utils;

namespace AppsGenerator.WebGenerators.WebControllerGenerator
{
    /// <summary>
    /// The class is reponsible for generating partial controller of user
    /// </summary>
    [Export(typeof(PartialControllerUserGenerator))]
    [PartCreationPolicy(CreationPolicy.NonShared)]
    public class PartialControllerUserGenerator : PartialControllerGenerator
    {
        /// <summary>
        /// Default constructor
        /// </summary>
        public PartialControllerUserGenerator()
        {
            // Start to deserialize xml template file
            this.XMLTemplate = "PartialControllerUserTemplate.xml";
            this.DeserializeTemplate();
            this.UpdateAlgorithm();
        }

        /// <summary>
        /// Initialize the algorithms for Delete, Update, Insert Item
        /// </summary>
        private void UpdateAlgorithm()
        {
            this._deleteAlgorithm = IoC.Get<DeleteControllerItemByUserAlgorithm>();
            this._updateAlgorithm = IoC.Get<UpdateControllerItemByUserAlgorithm>();
            this._insertAlgorithm = IoC.Get<InsertControllerItemByUserAlgorithm>();
        }
    }
}
